//
//  BLTimeAxisAppearance.m
//  BLTimeAxis
//
//  Created by dg on 2025/4/18.
//

#import "BLTimeAxisAppearance.h"
#import "BLTimeAxisRenderer.h"


@implementation BLTimeAxisAppearance
static BLTimeAxisAppearance *_instance = nil;

+ (instancetype)sharedAppearance {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[BLTimeAxisAppearance alloc] init];
        
        [_instance defaultInitial];
    });
    
    return _instance;
}

+ (instancetype)alloc {
    NSCAssert(!_instance, @"AxisAppearance类只能初始化一次");
    return [super alloc];
}

- (void)defaultInitial {
    _mainBackgroundColor = [UIColor blackColor];
    _rendererClass = [BLTimeAxisRenderer class];
    _direction = BLAxisDirectionHorizontal;
    
    _backgroundColor = [UIColor whiteColor];
    _backgroundStrokeSize = 0.0;
    _backgroundStrokeSizeType = BLStrokeSizeTypeFlexible;
    
    _ruleColor = [UIColor whiteColor];
    _ruleFixedOffset = 0.0;
    _ruleStrokeSize = 1.0;
    _ruleOffsetLocationType = BLStrokeLocationTypeMiddle;
    
    _divisionColor = [UIColor whiteColor];
    _divisionStrokeSize = 1.0;
    _digitalAttribute = @{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:[UIColor whiteColor]};
    
    _baseLineColor = [UIColor whiteColor];
    _baseLineStrokeSize = 1.0;
    _baseLineFixedOffset = 0.0;
    _baseLineOffsetLocationType = BLStrokeLocationTypeFlexible;
    
    _minimumScale = 1.0;
    _maximumScale = 2.0;
    _oneToOneScaleMatchMaxHoursInVisible = 4;
    
    _dataStrokeColor = [UIColor blueColor];
    _dataStrokeSize = 1.0;
    _dataStrokeSizeType = BLStrokeSizeTypeFull;
}

- (void)setRendererClass:(Class)rendererClass {
    NSAssert(![rendererClass isKindOfClass:[BLTimeAxisRenderer class]], @"renderClass must be subclass of BLTimeAxisRender");
    _rendererClass = rendererClass;
}

- (void)updateAppearance {
    [[NSNotificationCenter defaultCenter] postNotificationName:KBLAppearanceUpdateNotificationName object:nil];
}

@end
